<template>
  <div class="home-container">
    <div class="banner">
      <div class="banner-content">
        <h1 class="banner-title">简单工具集</h1>
        <p class="banner-desc">提供各种实用的在线工具，提高您的工作效率</p>
        <el-button type="primary" size="large" @click="goToTools">立即使用</el-button>
      </div>
    </div>

    <div class="features">
      <div class="feature-item">
        <el-icon class="feature-icon"><Tools /></el-icon>
        <h3>丰富的工具</h3>
        <p>提供多种类型的实用工具，满足您的各种需求</p>
      </div>
      <div class="feature-item">
        <el-icon class="feature-icon"><Monitor /></el-icon>
        <h3>在线使用</h3>
        <p>无需下载安装，随时随地在线使用</p>
      </div>
      <div class="feature-item">
        <el-icon class="feature-icon"><Lock /></el-icon>
        <h3>安全可靠</h3>
        <p>数据本地处理，保障您的信息安全</p>
      </div>
    </div>

    <div class="popular-tools">
      <h2 class="section-title">热门工具</h2>
      <div class="tool-cards">
        <el-card v-for="tool in popularTools" :key="tool.id" class="tool-card" @click="goToToolDetail(tool.id)">
          <div class="tool-icon">
            <el-icon><component :is="tool.icon" /></el-icon>
          </div>
          <h3 class="tool-name">{{ tool.name }}</h3>
          <p class="tool-desc">{{ tool.description }}</p>
        </el-card>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import { Tools, Monitor, Lock, Document, Picture, Calculator } from '@element-plus/icons-vue'

const router = useRouter()

const popularTools = ref([
  {
    id: 1,
    name: '文本处理',
    description: '文本格式化、转换、加密解密等功能',
    icon: 'Document'
  },
  {
    id: 2,
    name: '图片处理',
    description: '图片压缩、格式转换、水印添加等功能',
    icon: 'Picture'
  },
  {
    id: 3,
    name: '计算工具',
    description: '各种计算器、单位转换等功能',
    icon: 'Calculator'
  }
])

const goToTools = () => {
  router.push('/tools')
}

const goToToolDetail = (id: number) => {
  router.push(`/tool/${id}`)
}
</script>

<style scoped>
.home-container {
  width: 100%;
}

.banner {
  height: 500px;
  background: linear-gradient(135deg, #4b6cb7 0%, #182848 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  text-align: center;
}

.banner-content {
  max-width: 800px;
  padding: 0 20px;
}

.banner-title {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.banner-desc {
  font-size: 1.2rem;
  margin-bottom: 2rem;
  opacity: 0.9;
}

.features {
  display: flex;
  justify-content: space-around;
  padding: 80px 20px;
  background-color: #f5f7fa;
  flex-wrap: wrap;
}

.feature-item {
  flex: 1;
  min-width: 250px;
  text-align: center;
  padding: 20px;
}

.feature-icon {
  font-size: 3rem;
  color: #409eff;
  margin-bottom: 20px;
}

.popular-tools {
  padding: 80px 20px;
}

.section-title {
  text-align: center;
  margin-bottom: 40px;
  font-size: 2rem;
  color: #303133;
}

.tool-cards {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 30px;
}

.tool-card {
  width: 300px;
  cursor: pointer;
  transition: transform 0.3s;
}

.tool-card:hover {
  transform: translateY(-5px);
}

.tool-icon {
  font-size: 2.5rem;
  color: #409eff;
  margin-bottom: 15px;
  text-align: center;
}

.tool-name {
  font-size: 1.2rem;
  margin-bottom: 10px;
  color: #303133;
}

.tool-desc {
  color: #606266;
  font-size: 0.9rem;
}
</style> 